﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System.Windows;


namespace BaoVeBienCuong.SelectMap
{
    public class KyNang
    {
        public Texture2D image, imageSelect, imageLate, imageLateSelect;
        public Texture2D btNangCap;
        public Vector2 position;
        public Vector2 size;

        public bool isNangCap;
        public bool isSelect;
        public float scale;
        private int type;
        private long sao;
        private long vang;
        public KyNang(int t)
        {
            scale = 0.7f;
            type = t;
            isNangCap = false;
            isSelect = false;
            size = new Vector2(97, 97) * scale;
            position = new Vector2(100 + (t % 4) * 97, 100 + (t / 4) * 97);
        }

        public long getVang()
        {
            return vang;
        }
        public long getSao()
        {
            return sao;
        }
        public void setGia(int i)
        {
            switch (i)
            {
                case 0:
                    vang = 0;
                    sao = 2;
                    break;
                case 1:
                    vang = 6000;
                    sao = 3;
                    break;
                case 2:
                    vang = 9000;
                    sao = 3;
                    break;
                case 3:
                    vang = 12000;
                    sao = 4;
                    break;
                case 4:
                    vang = 0;
                    sao = 2;
                    break;
                case 5:
                    vang = 6000;
                    sao = 3;
                    break;
                case 6:
                    vang = 9000;
                    sao = 3;
                    break;
                case 7:
                    vang = 12000;
                    sao = 4;
                    break;
                case 8:
                    vang = 0;
                    sao = 1;
                    break;
                case 9:
                    vang = 0;
                    sao = 2;
                    break;
                case 10:
                    vang = 0;
                    sao = 2;
                    break;
                case 11:
                    vang = 0;
                    sao = 2;
                    break;
                case 12:
                    vang = 0;
                    sao = 0;
                    break;
                case 13:
                    vang = 00;
                    sao = 0;
                    break;
                case 14:
                    vang = 0;
                    sao = 0;
                    break;
                case 15:
                    vang = 0;
                    sao = 0;
                    break;


            }
        }
        public void Load(ContentManager content)
        {
            btNangCap = content.Load<Texture2D>("images/selectMap/mapScreenButton");
            image = content.Load<Texture2D>("images/store/lockedSkill");
            imageSelect = content.Load<Texture2D>("images/store/lockedSelectedSkill");
            imageLate = content.Load<Texture2D>("images/store/skillButton");
            imageLateSelect = content.Load<Texture2D>("images/store/selectedSkill");
        }
        public void Draw(SpriteBatch sprite)
        {
            if (isNangCap)
            {
                if (isSelect)
                    sprite.Draw(imageLateSelect, position, new Rectangle((type % 4) * 97, (type / 4) * 97, 97, 97), Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
                else
                    sprite.Draw(imageLate, position, new Rectangle((type % 4) * 97, (type / 4) * 97, 97, 97), Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
            }
            else
            {

                if (isSelect)
                    sprite.Draw(imageSelect, position, new Rectangle((type % 4) * 97, (type / 4) * 97, 97, 97), Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
                else
                    sprite.Draw(image, position, new Rectangle((type % 4) * 97, (type / 4) * 97, 97, 97), Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
            }
        }

        public bool isTouch(Vector2 posi)
        {
            if (posi.X >= position.X && posi.X <= (position.X + size.X) && posi.Y >= position.Y && posi.Y <= (position.Y + size.Y))
            {
                MainPage.PlayHieuUng("Click",false);
                isSelect = true;
                return true;
            }
            else
            {
                isSelect = false;
                return false;
            }
        }

        public bool isTouchNangCap(Vector2 touch, int sao, int vang)
        {
            if (touch.X >= 549 && touch.Y >= 410)
            {

                return true;
            }
            else
            {

                return false;
            }
        }
    }
}
